package cn.wsxiot.jxl;

import java.io.File;
import java.io.IOException;

import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class Modify {
    /**
     * 修改.xls中的数据
     * 要先创建文件，即运行cn.wsxiot.jxldemo类
     * @param args
     */

    public static void main(String[] args) {
        try {
            File file = new File("jxl_test.xls");
            //获取工作薄
            Workbook wb = Workbook.getWorkbook(file);
            // 有已知工作薄创建可写工作薄
            WritableWorkbook wwb = Workbook.createWorkbook(file, wb);
            // 获取一个可写sheet
            WritableSheet sh = wwb.getSheet(0);
            int row = sh.getRows();
            Label label = null;
            label = new Label(0, row - 1, "a");
            sh.addCell(label);
            label = new Label(1, row - 1, "user1");
            sh.addCell(label);
            label = new Label(2, row - 1, "女");
            sh.addCell(label);
            wwb.write();
            wwb.close();
            wb.close();



        } catch (RowsExceededException e) {
            e.printStackTrace();
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IndexOutOfBoundsException e) {
            e.printStackTrace();
        } catch (WriteException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}